package com.mikao.config;

import com.mikao.common.DateFormater;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


/**
 * @author KennyDavid
 */
@ControllerAdvice
public class WebMvcConfig extends WebMvcConfigurerAdapter {


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //首页
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/management").setViewName("layout");

        //管理员
        registry.addViewController("/management/manager").setViewName("manager/manager_list");
        registry.addViewController("/management/role").setViewName("manager/role_list");
        registry.addViewController("/management/user").setViewName("user/user_list");
        registry.addViewController("/management/homeImage").setViewName("homeImage/home_page_list");
        registry.addViewController("/management/adv").setViewName("homeImage/adv_list");
        registry.addViewController("/management/goods").setViewName("goods/goods_list");
        registry.addViewController("/management/pointGoods").setViewName("goods/pointGoods_list");
        registry.addViewController("/management/feedback").setViewName("feedback/feedback_list");
        registry.addViewController("/management/service").setViewName("feedback/service_list");
        registry.addViewController("/management/type").setViewName("goods/type_list");
        registry.addViewController("/management/ticket").setViewName("activity/ticket_list");
        registry.addViewController("/management/discount").setViewName("activity/discount_list");
        registry.addViewController("/management/order").setViewName("order/order_list");
        registry.addViewController("/management/tree").setViewName("plant/tree_list");
        registry.addViewController("/management/aboutPrice").setViewName("plant/aboutPrice_list");
        registry.addViewController("/management/treeOrder").setViewName("plant/recycleTreeOrder_list");
        registry.addViewController("/management/ss").setViewName("plant/recycleFruitOrder_list");
        registry.addViewController("/management/fruitMarket").setViewName("plant/fruitMarket_list");
        registry.addViewController("/management/treeMarket").setViewName("plant/treeMarket_list");
        registry.addViewController("/management/withdraw").setViewName("user/withdraw_list");

        super.addViewControllers(registry);
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(new DateFormater());
    }
}
